<?xml version="1.0" encoding="utf-8"?>
<%@ page contentType="application/xhtml+xml;charset=utf-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Administration</title>
        <link rel="stylesheet" href="/TrinityStripes/style.css" type="text/css"/>
    </head>
    <body>
        <c:out value="You are logged as user: "/><strong>${loggedUser}</strong><br/>
        <c:if test="${sessionScope.user ne loggedUser}">
            <c:out value="You are impersonating user: "/><strong>${sessionScope.user}</strong><br/>
        </c:if>
        <stripes:form beanclass="cz.muni.fi.xvano1.trinity.beans.ActionManagerActionBean">
            <stripes:submit name="home" value="Return to home page"/>
        </stripes:form>
        <stripes:form beanclass="cz.muni.fi.xvano1.trinity.beans.AdminActionBean">
            <c:if test="${sessionScope.user eq loggedUser}">
                <stripes:submit name="impersonate" value="Switch to other user"/>
            </c:if>
            <c:if test="${sessionScope.user ne loggedUser}">
                <stripes:submit name="resetUser" value="Switch to own account"/>
            </c:if>
            <stripes:submit name="printSysConf" value="Print system configuration"/>
        </stripes:form>

        <br/><br/><br/>
        <c:if test="${changeUser eq true}">
            <stripes:form beanclass="cz.muni.fi.xvano1.trinity.beans.AdminActionBean">
                <c:out value="Please select target user."/><br/><br/>
                <c:out value="Target user: "/><stripes:text name="user"/><br/>
                <stripes:submit name ="impersonate" value="Change"/>
            </stripes:form>
        </c:if>

        <c:if test="${showOptions eq true}">
            <stripes:form beanclass="cz.muni.fi.xvano1.trinity.beans.AdminActionBean">
                <c:out value="Please select action."/><br/><br/>
                <stripes:submit name ="core" value="Core configuration"/>
                <stripes:submit name ="userList" value="List of users"/>
            </stripes:form>
        </c:if>

        <c:if test="${printConf eq true}">
            <div id="config">
                <hr/>
                <c:out value="Content of config.dat is as follows:"/><br/><br/>
                ${configData}
                <hr/>
                <c:out value="System interpretation and used values are:"/><br/>
                <h4>
                    Years:
                </h4>
                <ul>
                    <c:forEach var="year" items="${applicationScope.yearList}">
                        <li>
                            <c:out value="${year}"/>
                        </li>
                    </c:forEach>
                </ul>
                <h4>
                    Administrators:
                </h4>
                <ul>
                    <c:forEach var="admin" items="${applicationScope.admins}">
                        <li>
                            <c:out value="${admin}"/>
                        </li>
                    </c:forEach>
                </ul>
            </div>
        </c:if>
        <c:if test="${printUsers eq true}">
            <div id="userList">
                <hr/>
                <c:out value="Following are users active in the system:"/><br/><br/>
                <h4>
                    Users:
                </h4>
                <ul>
                    <c:forEach var="user" items="${users}">
                        <li>
                            <c:out value="${user}"/>
                        </li>
                    </c:forEach>
                </ul>
            </div>
        </c:if>
    </body>
</html>
